package quantum.error.correcting.code.finalone;

/**
 * @author sunkai
 * @version 09-03-27
 * 
 */
public class Code {
	
	private int codeLen;
	
	private String codeName;
	/**
	 * 
	 */
	private String seriesStr = "";
	/**
	 * 
	 */
	private int len = 0;

	/**
	 * @return
	 */
	public int getLen() {
		return this.len;
	}

	/**
	 * @param len
	 */
	public void setLen(int len) {
		this.len = len;
	}

	/**
	 * @return
	 */
	public String getSeriesStr() {
		return this.seriesStr;
	}

	/**
	 * @param seriesStr
	 */
	public void setSeriesStr(String seriesStr) {
		this.seriesStr = seriesStr;
		this.len = seriesStr.length();
	}

	/**
	 * @param s
	 */
	public Code(String s) {
		this.seriesStr = s;
		this.len = this.seriesStr.length();
	}

	/**
	 * @return
	 */
	public boolean isZero() {
		char[] chs = this.seriesStr.toCharArray();
		for (int i = 0; i < this.len; ++i)
			if (chs[i] == '1')
				return false;

		return true;
	}

	/**
	 * @return
	 */
	public boolean isOne() {
		char[] chs = this.seriesStr.toCharArray();
		for (int i = 0; i < this.len; ++i)
			if (chs[i] == '0')
				return false;

		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return this.seriesStr;
	}

	public String getCodeName() {
		return codeName;
	}

	public void setCodeName(String codeName) {
		this.codeName = codeName;
	}

	public int getCodeLen() {
		return codeLen;
	}

	public void setCodeLen(int codeLen) {
		this.codeLen = codeLen;
	}
}